package io.renren.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.vo.RV;
import io.renren.modules.sys.entity.Org;
import io.renren.modules.sys.service.OrgService;



/**
 * 组织信息(创建组织时可以给组织分配组权限)
 *
 * @author jingtang
 * @email sunlightcs@gmail.com
 * @date 2018-06-28 08:41:11
 */
@RestController
@RequestMapping("sys/org")
public class OrgController extends AbstractController{
    @Autowired
    private OrgService orgService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:org:list")
    public RV list(@RequestParam Map<String, Object> params){
        

        return RV.ok();
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orgId}")
    @RequiresPermissions("sys:org:info")
    public RV info(@PathVariable("orgId") String orgId){
			Org org = orgService.selectById(orgId);

        return RV.ok(org);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:org:save")
    public RV save(@RequestBody Org org){
			orgService.insert(org);

        return RV.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:org:update")
    public RV update(@RequestBody Org org){
			orgService.updateById(org);

        return RV.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:org:delete")
    public RV delete(@RequestBody String[] orgIds){
			orgService.deleteBatchIds(Arrays.asList(orgIds));

        return RV.ok();
    }

}
